{include file="public/head"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">编辑权限</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" wid100 lay-filter="">
                    
						<div class="layui-form-item">
                            <label class="layui-form-label">所属位置</label>
                            <div class="layui-input-inline">
                                <select name="pid" lay-verify="required">
                                    <option value="0">一级菜单</option>
                                    {volist name="navList" id="vo"}
                                    <option {if isset($rule)&&($rule.pid eq $vo.id)}selected{/if} value="{$vo.id}">{$vo.lefthtml}{$vo.title}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>                    
                    
                        <div class="layui-form-item">
                            <label class="layui-form-label">权限名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" value="{$rule.title|default=''}" class="layui-input" lay-verify="required" autocomplete="off" placeholder="请输入权限名称">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">控制器/方法</label>
                            <div class="layui-input-inline">
                                <input type="text" name="url" lay-verify="required" value="{$rule.url|default=''}" placeholder="请输入控制器/方法" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">菜单名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" lay-verify="required" value="{$rule.name|default=''}" placeholder="请输入菜单名" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">图标名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="icon" value="{$rule.icon|default=''}" placeholder="请输入图标名称" autocomplete="off" class="layui-input">
                            </div><div class="layui-input-inline openViewIcon" style="cursor:pointer;">查看图标</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">菜单状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="menustatus" value="1" title="开启" {if(isset($rule)&&$rule.menustatus == 1)}checked {/if} >
                                <input type="radio" name="menustatus" value="0" title="关闭" {if((isset($rule)&&$rule.menustatus == 0)||empty($rule))}checked {/if} >
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline"  style="width: 80px;">
                                <input type="text" name="sort" value="{$rule.sort|default=''}" placeholder="排序编号" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="id" value="{$rule.id|default=''}">
                                <button class="layui-btn" lay-submit lay-filter="edit-btn">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYDMIN__',{if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','form'],function(){
		
		var $ = layui.$, admin = layui.admin, table = layui.table, element = layui.element, form = layui.form,util = layui.util, upload = layui.upload;
		var uri="{if isset($id)}{:url(SYS_PATH.'/'.CONTROLLER.'/edit')}{else}{:url(SYS_PATH.'/'.CONTROLLER.'/add')}{/if}";
				
		//提交编辑
		form.on('submit(edit-btn)', function(data){
			admin.req({
					url: uri
					, type: 'post'
					, data: data.field
					, success: function (res) {
								if(res.code==0){
									window.top.layer.msg(res.msg, {icon: 1, time: 1000,shade:[0.5,'#000000']}, function () {
										layer.closeAll("iframe");
										//刷新父页面
										parent.location.reload();
									});
								}else{
										window.top.layer.msg(res.msg, {icon: 2, time: 1000,shade:[0.5,'#000']});
										return;
								}
					}
				});
			});	
			
		$(".openViewIcon").click(function(){
			window.open('https://www.layui.com/doc/element/icon.html#table');
		});
			
	});
</script>
</body>
</html>